<template>
    姓名:
    <input type="text" v-model="cname"/>
    <input type="button" value="查询" @click="show()"/>
    <table class="table table-border" border="1">
        <tr style="background-color: aquamarine;">
            <td>用户名</td>
            <td>密码</td>
            <td>邮箱</td>
            <td>手机号</td>
            <td>时间</td>
            <td>操作</td>
        </tr>
        <tr v-for="item in info">
            <td>{{ item.name }}</td>
            <td>{{ item.pwd }}</td>
            <td>{{ item.email }}</td>
            <td>{{ item.phone }}</td>
            <td>{{ item.ctime.substring(0,10) }} {{ item.ctime.substring(11,16) }}</td>
            <td>操作</td>
        </tr>
    </table>
</template>

<script setup lang="ts">
import { ref,onMounted } from 'vue';
import axios from 'axios';
onMounted(()=>{
    show();
})
const info=ref([{
    "id": 0,
  "name": "",
  "pwd": "",
  "email": "",
  "phone": "",
  "ctime": ""
}])
//查询变量
const cname=ref("");
const show=()=>{
    axios.get("https://localhost:7258/api/user/userlist?name="+cname.value).then(res=>{
        console.log(res.data);
        info.value=res.data;
    })
}
</script>

